Attribute VB_Name = "modACStartup"
Option Explicit

' modACStartup.bas - Startup routine for The New Accessible Chat

' This module's only purpose is to get
' Nightowl running.
' It houses the main subroutine.

' This file is part of Nightowl.
'
' Nightowl is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.

' Nightowl is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.

' You should have received a copy of the GNU General Public License
' along with Nightowl.  If not, see <http://www.gnu.org/licenses/>.



Public Sub Main()


Dim c As Byte
Dim bl As Byte
Dim ts As String

' Welcome.

' Set initial constants
IniFile = App.Path & "\settings\settings.ini"
ServerListFile = App.Path & "\settings\servers.ini"
LangPath = App.Path & "\lang\"
ThemePath = App.Path & "\sounds"
Set IM = New IniManager


' Should we write logs?
'uncomment at v1.0
'If InStr(UCase$(Command$), "/LOG") Then
  Open "system.log" For Output As #3
  Open "irc.log" For Output As #4
  modAC.WriteDebugs = True
'End If

' Read settings into memory
modAC.LoadSettings

'load the language file
If Settings.Language = "" Then
LoadLang App.Path & "\lang\english.lng"
  frmLang.Show vbModal, frmMain
  Else
  LoadLang (LangPath & Settings.Language & ".lng")
End If


If App.PrevInstance Then
MsgBox SPrintF(lang.Messages(70), SoftwareName), vbOKOnly + vbCritical, lang.Messages(20)
End
End If

'Init and load the sounds
'SoundInit
If SoundSupport Then
'LoadSounds
End If

' If a speech type hasn't yet been defined, define it.
If Settings.SpeechType = -1 Then
  frmSpeech.Show vbModal ', frmMain
End If

' Was a speech type set?
' If not exit.
If Settings.SpeechType = -1 Then End

' Load the main form into memory, but don't show it yet
Load frmMain

' Check the software version
If App.Major = 0 Then
    MsgBox SPrintF(lang.Messages(69), SoftwareName), vbInformation + vbOKOnly, lang.Messages(71)
End If

' Apply the blacklist
If Len(Settings.Blacklist) > 0 Then
  For bl = 1 To WordCount(Settings.Blacklist, "|")
    frmMain.IRCInterface.AddBlacklist GetWord(Settings.Blacklist, bl, "|")
  Next
End If

' Splash in!
frmSplash.Splash


' Show our main form
frmMain.Show



'Check if we need to load the server list
If Settings.ShowServersAtStartup = 1 Then
frmConnectManager.Show vbModal, frmMain
End If



End Sub

